package com.hurteng.stormplane;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.hurteng.stormplane.myplane.R;

public class ReadyActivity extends Activity {
    private RadioGroup rg_mode;
    private Button bt_start;
    private int mode;

    private TextView tv_welcome;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ready);
        Intent intent=getIntent();
        String nickName=intent.getStringExtra("nickName");
        rg_mode=findViewById(R.id.rg_mode);
        bt_start=findViewById(R.id.bt_start);
        tv_welcome=findViewById(R.id.tv_welcome);
        tv_welcome.setText("尊敬的"+nickName+"你好！请选择游戏难度");
        bt_start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mode=rg_mode.getCheckedRadioButtonId();
                MainActivity.actionStart(ReadyActivity.this,mode);
                Log.d("mode",String.valueOf(mode));
                finish();
            }
        });

    }
    public static void actionStart(Context context,String nickName){
        Intent intent=new Intent(context,ReadyActivity.class);
        intent.putExtra("nickName",nickName);
        context.startActivity(intent);
    }
}
